import {ChangeDetectorRef, Component} from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import {DomSanitizer} from "@angular/platform-browser";
import {JidihttpProvider} from "../../providers/jidihttp/jidihttp";

/**
 * Generated class for the BozhuinfoPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@Component({
  selector: 'page-bozhuinfo',
  templateUrl: 'bozhuinfo.html',
})
export class BozhuinfoPage {
  jidiMovies: Array<any>=[];
  /** 列表 基地 **/
  tasklist:Array<any>=[];//list列表
  bozhu:string;
  bozhuid:string;
  bozhu_image:string;
  bozhu_name:string;
  bozhu_time:string;
  bozhu_jieshao:string;
  geyan_bozhu:string;
  /** zuopin **/
  zuopinlistitem:Array<any>=[];//list列表
  zuopinMoviesvaike: Array<any>=[];
  /** 是否显示 **/
  jidiBoolen:boolean=false;
  zuopinBoolen:boolean=false;

  constructor(public sanitizer:DomSanitizer,public navCtrl: NavController, public navParams: NavParams,public cdchange:ChangeDetectorRef,public jidiProvider:JidihttpProvider) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad KepujidiinfoPage');
    this.bozhuid=this.navParams.get('uuid')
    this.jidihttpInfoClinet(this.bozhuid);
  }

  /** 网络请求 **/
  jidihttpInfoClinet(uuid){
    this.jidiProvider.getBozhuInfoHttp(uuid).subscribe(data => {
      this.bozhu = data['data']['champion']["championName"];
      this.bozhu_name = data['data']['champion']["championName"];
      this.bozhu_time = data['data']['champion']["createTime"];
      this.bozhu_image = data['data']['champion']["img"];
      this.bozhu_jieshao = data['data']['champion']["championRemark"];
      this.geyan_bozhu = data['data']['champion']["sign"];
      //获取基地信息
      if(data['data']['popularScienceBases']['length']>0) {
        this.jidiBoolen=true;
        for (let i = 0; i < data['data']['popularScienceBases']['length']; i++) {
          this.jidiMovies.push(data['data']['popularScienceBases'][i]);
        }
        //alert(this.jidiMovies);
        this.tasklist = this.jidiMovies;
      }

      //获取作品信息
      if(data['data']['worksDetailsList']['length']>0) {
        this.zuopinBoolen=true;
        for (let i = 0; i < data['data']['worksDetailsList']['length']; i++) {
          this.zuopinMoviesvaike.push(data['data']['worksDetailsList'][i]);
        }
        //alert(this.jidiMovies);
        this.zuopinlistitem = this.zuopinMoviesvaike;
      }

      this.cdchange.detectChanges();

    },error => {

    });

  }
  assembleHTML(strHTML:any){
    return this.sanitizer.bypassSecurityTrustHtml(strHTML);
  }

}
